#include <CODEPORTS/codeports.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
	BOX box;
	int w, h, div, move;
	unsigned int x, y;

	CP_Init();
	SCR_GetSize(&w, &h);

	div = argc < 3 ? 1 : atoi(argv[2]);
	move = argc < 4 ? (div > 1) : atoi(argv[3]);
	BOX_Allocate(&box, w / div, h / div);
	BOX_SetImage(&box, argv[1]);

	for(x = (w - box.info.width) / 2, y = (h - box.info.height) / 2; !KEY_Update(); x += move ? rand() % 10 - 5 : 0, y += move ? rand() % 10 - 5 : 0)
	{
		SWP_Clear();
	
		SWP_SetBox(x % w, y % h, &box);

		SWP_Screen();
	}

	BOX_Free(&box);

	//SCR_Clear();
	CP_Final();

	return EXIT_SUCCESS;
}
